package com.chey.service.impl;

import com.chey.dao.EchartsDao;
import com.chey.domain.Day;
import com.chey.domain.Area;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author JanYao
 * @version 0.1
 */
@Service
public class EchartsServiceImpl implements com.chey.service.EchartsService {
    @Autowired
    private EchartsDao echartsDao;
    @Override
    public Area getEchartsAreaData() {
        Area echartsAreaData = echartsDao.getEchartsAreaData();
        return echartsAreaData;
    }

    @Override
    public Map<String, List<Day>> getEchartsADData() {
        List<Day> echartsAData = echartsDao.getEchartsAData();
        List<Day> echartsDData = echartsDao.getEchartsDData();
        Map<String, List<Day>> DayMap = new HashMap<>();
        DayMap.put("entry",echartsAData);
        DayMap.put("out",echartsDData);
        return DayMap;
    }

    @Override
    public Map<String, Integer> getExceptionCounts() {
        Integer cancelCounts = echartsDao.getCancelCounts();
        Integer delayCounts = echartsDao.getDelayCounts();
        HashMap<String, Integer> exceptionMap = new HashMap<>();
        exceptionMap.put("cancel",cancelCounts);
        exceptionMap.put("delay",delayCounts);
        return exceptionMap;
    }
}


